<template>
  <div>
    <p>3. vue更新DOM是异步的</p>
    <p ref="myP">{{ count }}</p>
    <button @click="btn">点击count+1, 马上提取p标签内容</button>
  </div>
</template>


<script>
export default {
  data() {
    return {
      count: 1,
    };
  },
  methods: {
    btn() {
      this.count++;
      console.log("在外面", this.$refs.myP.innerHTML);
      //DOM更新后，会挨个触发$nextTick里的回调函数
      this.$nextTick(() => {
        console.log("$nextTick回调函数内", this.$refs.myP.innerHTML);
      });
    },
  },
};
</script>

<style>
</style>